---
sidebar_position: 2
description: Learn how to use clients and roles in DeviceScript to interact with
    Jacdac services for sensors and actuators in a home heating system example.
keywords:
    - DeviceScript
    - Jacdac
    - clients
    - roles
    - home automation
---

# Clients

In DeviceScript, all access to sensors, actuators or other hardware components
are abstracted through **services**.
Sensors act as **servers** and your scripts connects **clients** to interact with them.
Servers are implemented by **drivers**, which may provide one or more services.

To interact with servers, you start clients, known as **roles**, for each service you need.

Let's illustrate these concept with a controller for a home heating system.
The heating system has a relay to turn on/off the furnace, a temperature sensor and
rotary encoder to change the desired temperature.
Therefore, we declare 3 roles.

```ts
import { Temperature, Relay } from "@devicescript/core"

const thermometer = new Temperature()
const thermometer2 = new Temperature()
const relay = new Relay()
```

## Onboard servers

You can also start servers for onboard sensors and actuators. For example, the `startBME680` function maps a BME680 sensor to 4 roles: temperature, humidity, pressure and air quality index.

```ts
import { startBME680 } from "@devicescript/drivers"

// mount services on a BME680
// highlight-next-line
const { temperature, humidity, pressure, airQualityIndex } = await startBME680()
```
